<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.situ.web.entity.Course"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
<style type="text/css">
	.right{
		float: right;
		height: 40px;
		
	}
</style>
</head>
<body>
	<div style="width: 800px; margin: 10px auto;">
		<a href="/Java202007Web/course_insert.jsp" class="btn btn-default btn-lg active right" role="button">添加</a>
		<form action="${pageContext.request.contextPath}/course?method=selectName" method="post">
			<input type="text" name="selectName" style="height: 36px;"/>
			<input type="submit" value="搜索"/ style="height: 36px; width: 50px;">
		</form>
		<table class="table table-hover table-bordered">
		<tr  class="warning">
			<td>ID</td>
			<td>课程名称</td>
			<td>学分</td>
			<td>修改</td>
			<td>删除</td>
		</tr>
	<%-- 	<% // 这里可以嵌套java代码
			// request是jsp页面的内置对象，我们可以直接使用
			// req.setAttribute("list", list);
			// 从request里面拿出list数据
			List<Course> list = (ArrayList<Course>)request.getAttribute("list");
			for	 (Course course :list) {
				// 每遍历一个student就在table中打印一行数据tr
		%>
			<tr>
				<td><%=course.getId()%></td>
				<td><%=course.getName()%></td>
				<td><%=course.getCredit()%></td>
				<td><a href="/Java202007Web/course?method=selectId&id=<%=course.getId()%>">修改</a></td>
				<td><a href="/Java202007Web/course?method=delete&id=<%=course.getId()%>">删除</a></td>
			</tr>
		<%
			}
		%> --%>
		<c:forEach items="${list}" var="course">
			<tr>
				<td>${course.id}</td>
				<td>${course.name}</td>
				<td>${course.credit}</td>
				<td><a href="/Java202007Web/course?method=selectId&id=${course.id}">修改</a></td>
				<td><a href="/Java202007Web/course?method=delete&id=${course.id}">删除</a></td>
			</tr>
		</c:forEach>
	</div>
	
</body>
</html>